home *** CD-ROM | disk | FTP | other *** search
- unit Array8U;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls,
- Forms, Dialogs, Grids, StdCtrls;
-
- type
- TArray8MainForm = class(TForm)
- ListBox1: TListBox;
- btnResizeArray: TButton;
- btnFillArray: TButton;
- procedure FormCreate(Sender: TObject);
- procedure btnResizeArrayClick(Sender: TObject);
- procedure btnFillArrayClick(Sender: TObject);
- private
- MyArray: array of Integer;
- procedure DisplayArray;
- end;
-
- var
- Array8MainForm: TArray8MainForm;
-
- implementation
-
- {$R *.DFM}
-
- procedure TArray8MainForm.FormCreate(Sender: TObject);
- begin
- SetLength(MyArray, StrToInt(InputBox(
- 'Enter your array dimensions',
- 'Number of elements:', '10')));
- btnFillArray.Click; { Pretend to push the array filling button }
- DisplayArray
- end;
-
- procedure TArray8MainForm.btnResizeArrayClick(Sender: TObject);
- begin
- SetLength(MyArray, StrToInt(InputBox(
- 'Enter your new array dimensions',
- 'Number of elements:', '20')));
- DisplayArray
- end;
-
- procedure TArray8MainForm.btnFillArrayClick(Sender: TObject);
- var
- Loop: Integer;
- begin
- for Loop := Low(MyArray) to High(MyArray) do
- MyArray[Loop] := Loop;
- DisplayArray
- end;
-
- procedure TArray8MainForm.DisplayArray;
- var
- Loop: Integer;
- begin
- with ListBox1, Items do
- begin
- BeginUpdate;
- try
- Clear;
- for Loop := Low(MyArray) to High(MyArray) do
- Add(IntToStr(MyArray[Loop]));
- ItemIndex := High(MyArray)
- finally
- EndUpdate
- end
- end
- end;
-
- end.
-